﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Mechanical;

namespace YArchitech.HCLoad.Export
{
	public partial class LevelInfoForm : System.Windows.Forms.Form
	{
		public LevelInfoForm()
		{
			this.InitializeComponent();
		}

		public LevelInfoForm(HcDataManager dataManager)
		{
			this.m_dataManager = dataManager;
			this.InitializeComponent();
		}

		private void LevelInfoForm_Load(object sender, EventArgs e)
		{
			foreach (Level level in this.m_dataManager.Levels)
			{
				this.listBox_Levels.Items.Add(level.Name);
			}
			this.listBox_Levels.SelectedIndex = 0;
			this.listBox_Levels_SelectedIndexChanged(sender, e);
		}

		private void listBox_Levels_SelectedIndexChanged(object sender, EventArgs e)
		{
			int selectedIndex = this.listBox_Levels.SelectedIndex;
			Level level = this.m_dataManager.Levels[selectedIndex];
			List<Space> spaces = this.m_dataManager.GetSpaces(level);
			this.listView_Spaces.Clear();
			this.listView_Spaces.Columns.Insert(0, this.columnHeader_SpaceName);
			this.listView_Spaces.Columns.Insert(1, this.columnHeader_Area);
			foreach (Space space in spaces)
			{
				SpaceItem value = new SpaceItem(space);
				this.listView_Spaces.Items.Add(value);
			}
		}

		private void button_Cancel_Click(object sender, EventArgs e)
		{
			base.Close();
		}

		private HcDataManager m_dataManager;
	}
}
